package client.GUI;

import java.awt.Button;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * The Class ErrorGui
 * - used to display error messages.
 */
public class ErrorGui extends JPanel{

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -1111073421159451687L;
	
	/** The error gui window. */
	JFrame aken;
	
	/** The error to be displayed. */
	String error;

	/**
	 * Instantiates a new error gui.
	 *
	 * @param error the error
	 */
	public ErrorGui(String error) {
		this.error = error;
		run();
	}

	/**
	 * Run - creates the error gui window and displays the error message.
	 */
	public void run() {
		aken = new JFrame("Veateade!");
		aken.setSize(400, 75);
		aken.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		aken.setVisible(true);
		JLabel lbl = new JLabel();
		lbl.setText(error);
		lbl.setVisible(true);
		Button OK = new Button("OK");
		aken.add(this);
		this.add(lbl);

		OK.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseReleased(MouseEvent e) {
				System.exit(0);
			}
		});
		this.add(OK);
	}
}
